from django.db import models

# Create your models here.
class userinfo(models.Model):
    user_id =  models.AutoField(primary_key = True)
    user_name = models.CharField(max_length=255)
    user_alias = models.CharField(max_length=255,default="0")
    user_password = models.CharField(max_length=255)
    user_status =  models.CharField(max_length=13,default=0) #是否是管理员
    user_show = models.CharField(max_length=13,default=0) #是否允许查看所有文件列表,0表示不支持,1表示只查看归属项目,2表示查看所有
    user_del_file = models.CharField(max_length=13,default=0) #设置是否具有删除文件权限,0表示不支持，1表示支持删除文件
    user_active = models.CharField(max_length=13,default=1)  #表示启用
    user_project =  models.ManyToManyField("projectinfo")
    user_url = models.ManyToManyField("url_limit")


class projectinfo(models.Model):
    project_id = models.AutoField(primary_key = True)
    project_name = models.CharField(max_length=255)
    project_alias = models.CharField(max_length=255)
    project_ctime = models.CharField(max_length=255)


class url_limit(models.Model):
    url_id = models.AutoField(primary_key = True)
    url_path = models.CharField(max_length=255)
    url_alias = models.CharField(max_length=255)

class log_record(models.Model):
    log_id = models.AutoField(primary_key = True)
    user_name = models.CharField(max_length=255)
    log_content = models.CharField(max_length=255)
    log_ctime = models.CharField(max_length=255)

class fileinfo(models.Model):
    file_id = models.AutoField(primary_key = True)
    file_name = models.CharField(max_length=255)
    file_path = models.CharField(max_length=255,default=0)
    web_path = models.CharField(max_length=255,default=0)
    file_url = models.CharField(max_length=255)
    file_ctime = models.CharField(max_length=255)
    file_md5 = models.CharField(max_length=255,default=0)
    file_satus = models.CharField(max_length=10,default=1) #表示使用
    file_cdn_status = models.CharField(max_length=255,default=888)
    file_cdn_time = models.CharField(max_length=255,default="未更新CDN") #刷新时间
    file_project = models.ManyToManyField("projectinfo")
    file_user = models.ManyToManyField("userinfo")

class cdnconfig(models.Model):
    cdn_id = models.AutoField(primary_key = True)
    cdn_name = models.CharField(max_length=32)
    api_url = models.CharField(max_length=255,default="0")
    cdn_enable = models.CharField(max_length=32, default="0")
    access_key_id = models.CharField(max_length=255,default="0")
    access_key_secret = models.CharField(max_length=255,default="0")
class sysconfig(models.Model):
    sys_id = models.AutoField(primary_key = True)
    api_name = models.CharField(max_length=32)
    apk_url = models.CharField(max_length=255,default="http://www.baidu.com")
